<?php
$bool_IE     = false;

if( strpos( $_SERVER["HTTP_USER_AGENT"], "MSIE" ) !== false ) $bool_IE = true;
?>
<div class="tab_menu" style="position: relative;bottom: -8px;*bottom: -28px;">
    <div class="tab_control tab_selected"> Quản Lý </div>
    <div class="tab_control" onclick="load_page('<?=$this->createAbsoluteUrl('images/edit')?>');"> Thêm Mới </div>
</div>
<div class="clear"></div>
<div class="box" style="float: left;">
    <?php if ( isset($s_errMsg) && !is_null($s_errMsg) ) {?>
        <div class="box_content_no_border">
            <p class="error_message"><?=$s_errMsg?></p>
        </div>
    <?php } ?>
    <form class="form_input" action="" method="post" id="form_item" name="form_item">
        <fieldset class="border_radius_all">
            <legend></legend>
            
            <div class="form_input_row">
                <label class="label_title">Tìm Kiếm:</label>
                <input
                    id            = "txt_filter"
                    name        = "txt_filter"
                    title        = "Tìm Kiếm"
                    type        = "text"
                    class        = "form_textbox textbox_css3"
                    tabindex    = "1"
                />
            </div>
                
            <div class="form_input_row">
                <label class="label_title">Danh Mục Ảnh:</label>
                <select
                    id            = "sl_type"
                    name        = "sl_type"
                    title        = "Danh Mục Ảnh"
                    tabindex    = "2"
                    <?php
                    if ($bool_IE != true)
                        echo "class = 'form_combobox select_css3 select_two_arrown'";
                    else
                        echo "class = 'form_combobox'";
                    ?>
                >
                    <?php 
                    foreach ($arr_library as $index => $o_library)
                        if ( ($o_library instanceof Library) == true )
                        {
                    ?>
                        <option value="<?=$o_library->key;?>"> <?=$o_library->name;?> </option>
                    <?php }?>
                </select>
            </div>
        
        </fieldset>
    </form>
    <div class="clear"></div>

    <div class="box_content_no_border" id="div_contentBox" style="float:left;width: 99.5%;">

    </div><!--End box_content_no_border-->
</div><!--End box-->

<div
    id        = "dialog_excute"
    title    = "Chương trình đang thực thi"
    class    = "dialog_message"
>
    <p class="center">
        <img alt="Loading...." src="<?=Yii::app()->baseUrl;?>/images/image_default/loading_circle.gif" width="92px" height="92px"/>
    </p>
</div> <!--End dialog_excute-->
    
<div
    id        = "dialog_notice"
    title    = "Người Dùng"
    class    = "dialog_message"
>
    <div id="content">
    </div>
</div><!--End dialog_notice-->

<script type="text/javascript">

$(document).ready(function () {

    $("#dialog_excute").dialog({
        autoOpen: false,
        closeOnEscape: false,
        width: 220,
        height: 152,
        modal: true,
        resizable: false,
        show: "explode",
        hide: "explode",
        open: function (event, ui) { $(".ui-dialog-titlebar-close").hide(); }
    });

    $("#dialog_notice").dialog({
        autoOpen: false,
        closeOnEscape: true,
        width: "90%",
        height: "auto",
        modal: true,
        show: "explode",
        hide: "explode"
    });

    $("#sl_type").change( function()
    {
        create_list($(this).val(), 1);
    });
});

function create_list(s_type, i_page)
{
    $.ajax({
        url     : "<?=Yii::app()->createUrl("images/list")?>",
        type    : "POST",
        cache   : false,
        data    : {
            page: i_page,
            amountPerPage: 20,
            txt_filter: $("#txt_filter").val(),
            sl_type: s_type
        },
        dataType : "html",
        success  : function(html)
        {
            $("#div_contentBox").html(html);
        },
        error: function ()
        {
            alert("Trang hiện hành không tồn tại.");
        }
    });
}
</script>